home *** CD-ROM | disk | FTP | other *** search
/ Gekkan Dennou Club 147 / Gekkan Dennou Club - 2000.8 Vol. 147 (Japan).7z / Gekkan Dennou Club - 2000.8 Vol. 147 (Japan) (Track 1).bin / tools / ex68v209 / ex68v209.lzh / X6_UTIL.LZH / getrom.c next >
Text File  |  2000-05-13  |  1KB  |  59 lines

  1.  
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <mem.h>
  5.  
  6. #define BUFFSIZE 0x4000
  7.  
  8. int exw(unsigned char *pt,int len,FILE *fp)
  9. {
  10. unsigned char *buff;
  11. int block;
  12. int total;
  13.     total=0;
  14.     buff=(unsigned char *)malloc(BUFFSIZE);
  15.     if (buff==NULL)
  16.         return -1;
  17.     while(len>0)
  18.     {
  19.         block=BUFFSIZE;
  20.         if (len<BUFFSIZE)
  21.             block=len;
  22.         memcpy(buff,pt,block);
  23.         if (fwrite(buff,1,block,fp)!=block)
  24.         {
  25.             free(buff);
  26.             return -1;
  27.         }
  28.         total+=block;
  29.         len-=block;
  30.         pt=&pt[block];
  31.     }
  32.     free(buff);
  33.     return total;
  34. }
  35.  
  36. void main()
  37. {
  38. FILE *fp;
  39. int ssp;
  40.     ssp=SUPER(0);
  41.     fp=fopen("cg.rom","wb");
  42.     if (fp==NULL)    exit(1);
  43.     if (exw((unsigned char *)0xf00000,0xc0000,fp) != 0xc0000)
  44.         exit(1);
  45.     fclose(fp);
  46.     
  47.     fp=fopen("boot.rom","wb");
  48.     if (fp==NULL)    exit(1);
  49.     if (exw((unsigned char *)0xfe0000,0x20000,fp) != 0x20000)
  50.         exit(1);
  51.     
  52.     fp=fopen("sram.ram","wb");
  53.     if (fp==NULL)    exit(1);
  54.     if (exw((unsigned char *)0xed0000,0x4000,fp) != 0x4000)
  55.         exit(1);
  56.     fclose(fp);
  57.     SUPER(ssp);
  58. }
  59.